package com.sise.parkinglot.controller;

import com.sise.parkinglot.bean.CodeMsg;
import com.sise.parkinglot.entity.User;
import com.sise.parkinglot.service.IUserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author ZJ
 */
@RestController
@RequestMapping("/parkinglot/user")
public class UserController {

    @Resource
    private IUserService userService;

    @PostMapping("/queryUserList")
    public CodeMsg<List<User>> queryUserList(@RequestBody Map<String, Object> map) {
        return userService.queryUserList(map);
    }

    @PostMapping("/addUser")
    public CodeMsg<String> addUser(@RequestBody User user) {
        return userService.addUser(user);
    }

    @PostMapping("/frozenUser")
    public CodeMsg<String> frozenUser(@RequestBody int[] carIds) {
        return userService.frozenUser(carIds);
    }

    @PostMapping("/removeUser")
    public CodeMsg<String> removeUser(@RequestBody int[] carIds) {
        return userService.removeUser(carIds);
    }

    @PostMapping("/thawUser")
    public CodeMsg<String> thawUser(@RequestBody int[] carIds) {
        return userService.thawUser(carIds);
    }

    @PostMapping("/updateUser")
    public CodeMsg<String> updateUser(@RequestBody User user) {
        return userService.updateUser(user);
    }

    @PostMapping("/addWalletUser")
    public CodeMsg<String> addWalletUser(@RequestBody Map<String, String> map) {
        return userService.addWalletUser(map);
    }
}
